class Solution {
public:
    string countAndSay(int n) {
        vector<int> vec{1};
        for(int i = 0; i < n - 1; i++)
        {
            vector<int> cur_vec;
            int count = 1;
            int cur_int = vec[0];
            for(int j = 1; j < vec.size(); j++)
            {
                if(vec[j] == vec[j - 1])
                    count++;
                else
                {
                    cur_vec.push_back(count);
                    cur_vec.push_back(cur_int);
                    cur_int = vec[j];
                    count = 1;
                }
            }
            cur_vec.push_back(count);
            cur_vec.push_back(cur_int);
            string ans;
            vec = cur_vec;
        }
        string ans;
        for(int n : vec) ans += to_string(n);
        return ans;
    }
};
